﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using NewDDSys.Entity;
using NewDDSys.IBLL;
using NewDDSys.IDAL;
using NewDDSys.Factory;
using NewDDSys.Utility;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;


public partial class Web_KNCCX : System.Web.UI.Page
{
    private string Ku = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["用户信息.岗位"].ToString() != "库管" && Session["用户信息.岗位"].ToString() != "作业长")
        {
            Ku = Request.QueryString["Ku"];
        }
        else
            Ku = Session["用户信息.部门"].ToString();
        ShowList(Ku);
    }
    public string GetCut(string str, int len)
    {
        //如果字符串的长度大于传入的规定长度，多余的部分则用...代替，否则，直接返回该字符串
        if (str.Length > len)
        {
            return str.Substring(0, len) + "...";
        }
        else
        {
            return str;
        }
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        ShowList(Ku);
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            string num = (string)((DataRowView)e.Row.DataItem).Row.ItemArray[0];
            string sta = (string)((DataRowView)e.Row.DataItem).Row.ItemArray[15];
            //when mouse over
            e.Row.Attributes.Add("onmouseover", "this.className='GridView_onmouseover';");
            //when mouse out
            e.Row.Attributes.Add("onmouseout", "this.className='GridView_onmouseout';");
            //将光标设为手形
            e.Row.Attributes.Add("style", "cursor: hand;");
            //行链接
            e.Row.Attributes.Add("onclick", "window.location='showdetails.aspx?Sta=" + sta + "&Num=" + num + "'");

            

        }
    }
    private void ShowList(string ku)
    {
        DataSet ds = null;
        ds = BLLFactory.CreateWorkBLL().SelectKN(ku);

        if (ds != null)
        {
            GridView1.DataSource = ds.Tables[0];
        }
        else
        {
            GridView1.DataSource = null;
        }
        GridView1.DataBind();
    }
}
